package com.lin.utils;

import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.Uri;

public class Net {
	private static final String TAG = "NetworkCheck";

	public static boolean IsNetworkAvailble(Context context) {
		try {
			ConnectivityManager connectivity = (ConnectivityManager) context
					.getSystemService("connectivity");
			if (connectivity != null) {
				NetworkInfo info = connectivity.getActiveNetworkInfo();
				if ((info != null) && (info.isConnected())) {
					if (info.getState() == NetworkInfo.State.CONNECTED) {
						return true;
					} else {
						return false;
					}
				}
			}
		} catch (Exception e) {
			return false;
		}
		return false;
	}
	
	public static void openBrower(Context context, String url) {
		Uri uri = Uri.parse(url);
		Intent intent = new Intent(Intent.ACTION_VIEW, uri);
		context.startActivity(intent);
	}
}